<!--#include file="../nav/top.php" -->
<!--#include file="../nav_menu/user_begin.php" -->

	
		<div class="infotitle">
			我的体质
		</div>  
	 <?PHP
	 if(!$rs){
	 ?>  
		<div class="infocontent" style="height:100px;">
			<table class="mytable" > 
				<tr>
					<td class="mylabel"> 体质测试结果：</td>
					<td class="myinfo" >
						未完成体质测试 
					</td> 
				</tr>
				<tr>
					<td class="mylabel">   </td>
					<td class="myinfo" > 
						<button class="userbtn" onclick="fnBodyMemberTest()" >我要测试</button>
					</td> 
				</tr>
			</table>
		</div>	 
		 <?PHP
		 }else{
		 ?> 
		<div class="infocontent" style="height:150px;">
			<table class="mytable" > 
				<tr>
					<td class="mylabel"> 您的主要体质：</td>
					<td class="myinfo" >
						{$rs.main_body}
					</td> 
				</tr>
				<tr>
					<td class="mylabel"> 您的兼有体质：</td>
					<td class="myinfo" >
						{$rs.pian_body}
					</td> 
				</tr>
				<tr>
					<td class="mylabel">   </td>
					<td class="myinfo" > 
						<button class="userbtn" onclick="fnBodyMemberTest()" >重新测试</button> 
						或 
						<a href="javascript:void(0)" style="color:#FF6633" onclick="fnBodyMemberDelete()" >删除测试结果</a>
					</td> 
				</tr>
			</table>
		</div>
		 <?PHP
		 }
		 ?>
		 <div style="height:30px;"></div>
		
<style type="text/css">

table.friendtb {
border-collapse: collapse;
width: 750px;
}
table.friendtb   td {
border: 2px solid #FFFFFF;
color: #060806;
font-size: 14px;
padding: 10px;
background-color:#E1EFD5;
}
table.friendtb   th {
    background: none repeat scroll 0 0 #6EB92B;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    padding: 7px;
    text-align: center;
}
table.friendtb   td a{
color:#666666;
}

</style>
		<div class="infotitle">
			亲友体质 <button onclick="fnAddFriend()" class="userbtn"  style="margin-left:20px;" >添加</button>
		</div>  
	
			<div style="height:10px;"></div>
		 
			<div style="margin-left:0px;margin-bottom:10px;">
				<table class="friendtb" > 
					<tr>
						<th > 称呼</th>
						<th > 性别</th>
						<th > 主要体质</th>
						<th > 兼有体质</th>
						<th >  </th>
					</tr>
					 <?PHP
					 if(count($rs_qin)>0){
							echo '
							';	
							foreach($rs_qin as $v){
								echo '
								<tr>
									<td>'.$v['name'].'</td>
									<td>'.$v['sex'].'</td> 
									<td>'.$v['main_body'].'</td> 
									<td>'.$v['pian_body'].'</td> 
									<td>
										<a href="javascript:void(0)"   onclick="fnFriendInfoModify('.$v['id'].')" >[修改]</a>
										<a href="javascript:void(0)"   onclick="fnBodyFriendModify('.$v['id'].')" >[重新测试]</a>
										<a href="javascript:void(0)"  onclick="fnBodyFriendDelete('.$v['id'].')" >[删除]</a>
									</td> 
								</tr>
								';
							 }
							echo '
							';
						}	
					 ?> 
			 	</table>
			</div>
		
<script type="text/javascript">
var url_modify = '/body/index';
var url_addfriend = '/user/addfriend';
var url_modifyfriend = '/user/modifyfriend';
var now_body_id=0;//当前正在操作的亲友体质测试ID 
$().ready(function(){
	o2js.build('ymprompt');
});	
function fnFriendInfoModify(body_id){
	ymPrompt.close();
	ymPrompt.win({
		title:'修改资料',
		fixPosition:true,
		maxBtn:true,
		width: 650, 
		height: 310,
		iframe:{
			src:url_modifyfriend+'?id='+body_id+'&endfunc=fnFriendInfoModifyEnd'
		}
	});
}
function fnFriendInfoModifyEnd(){
	window.location.reload();
}
/* 会员亲友体质测试 */
function fnAddFriend(){
	ymPrompt.close();
	ymPrompt.win({
		title:'输入家人朋友信息',
		fixPosition:true,
		maxBtn:true,
		width: 650, 
		height: 310,
		iframe:{
			src:url_addfriend+'?endfunc=fnBodyFriendModify'
		}
	});
}
function fnBodyFriendModify(body_id){
	now_body_id = body_id;
	ymPrompt.close();
	ymPrompt.win({
		title:'进行亲友体质测试',
		fixPosition:true,
		maxBtn:true,
		width: 650, 
		height: 510,
		iframe:{
			src:url_modify+'?endfunc=fnBodyFriendModifyEnd'
		}
	});	
}
function fnBodyFriendModifyEnd(results){
	$.ajax({
		async:true,
		type:'post',
		url:'/user/body_friend_modify',
		data:{
			body_id:now_body_id,
			main_body:JSON.encode(results.main_body),
			pian_body:JSON.encode(results.pian_body)
		},
		success:function(e){
			var ok = errorHandler(e);
			if(ok){
				window.location.reload();
			}
		}
	});
}
/* 亲友体质测试删除 */
function fnBodyFriendDelete(body_id){
	fnConfirm({
		str:"是否删除？",
		func_true:function(){
			$.ajax({
				async:true,
				type:'post',
				url:'/user/body_friend_delete',
				data:{
					body_id:body_id
				},
				success:function(e){
					var ok = errorHandler(e);
					if(ok){
						window.location.reload();
					}
				}
			});
		}
	});
}
//会员体质测试
function fnBodyMemberTest(){
	ymPrompt.close();
	ymPrompt.win({
		title:'体质测试',
		fixPosition:true,
		maxBtn:true,
		width: 650, 
		height: 510,
		iframe:{
			src:url_modify+'?endfunc=fnBodyMemberTestEnd'
		}
	});
}
function fnBodyMemberTestEnd(results){
	$.ajax({
		async:true,
		type:'post',
		url:'/user/body_member_modify',
		data:{
			main_body:JSON.encode(results.main_body),
			pian_body:JSON.encode(results.pian_body)
		},
		success:function(e){
			var ok = errorHandler(e);
			if(ok){
				window.location.reload();
			}
		}
	});
}
function fnBodyMemberDelete(){
	fnConfirm({
		str:"是否删除？",
		func_true:function(){
			$.ajax({
				async:true,
				type:'post',
				url:'/user/body_member_delete',
				data:{
				},
				success:function(e){
					var ok = errorHandler(e);
					if(ok){
						window.location.reload();
					}
				}
			});
		}
	});
}
</script>	 			
<!--#include file="../nav_menu/user_end.php" -->
<!--#include file="../nav/bottom.php" -->